Full source code website bán hàng thương mại điện tử gần giống shopee
468.910 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Currency : <b> <a href="./?act=currency_m"><font color="#FFFFFF">Nhập
5 mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $sql = "delete from currency where id='".$id."'";
14 @$result = mysql_query($sql,$con);
15 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
16 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
17 break;
18 }
19 ?>
20
21 <?
22 if (isset($_POST['ButDel'])) {
23 $cnt=0;
24 foreach ($_POST['chk'] as $id)
25 {
26 @$result = mysql_query("delete from currency where id='".$id."'",$con);
27 if ($result) $cnt++;
28 }
29 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
30 }
31 ?>
32 <?
33 $page = $_GET["page"];
34 $MAXPAGE=10;
35 $p=0;
36 if ($page!='') $p=$page;
37 ?>
38 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
39 <input type="hidden" name="act" value="currency">
40 <input type=hidden name="page" value="<? echo $page; ?>">
41 <?
42 function taotrang($sql,$link,$nitem,$itemcurrent)
43 { global $con;
44 $ret="";
45 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
46 $value = mysql_fetch_array($result);
47 $plus = (($value['cnt'] % $nitem)>0);
48 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
49 {
50 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
51 else $ret .= ($i+1)." ";
52 }
53 return $ret;
54 }
55 $pageindex=taotrang("select count(*) from currency","./?act=currency"."&page=",$MAXPAGE,$page);
56 ?>
57
58 <table cellspacing="0" cellpadding="0">
59 <tr>
60 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
61 </tr>
62 </table>
63
64 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
65 <tr>
66 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
67 <td nowrap class="title"> </td>
68 <td nowrap class="title"> </td>
69 <td align="center" nowrap class="title"><b>ID</b></td>
70 <td align="center" nowrap class="title"><b>Mã</b></td>
71 <td align="center" nowrap class="title"><b>Tên tiền</b></td>
72 <td align="center" nowrap class="title"><b>Quy đổi</b></td>
73 <td align="center" nowrap class="title"><b>Thứ tự</b></td>
74 </tr>
75
76 <?
77 $sql="select * from currency order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
78 $result=mysql_query($sql,$con);
79 $i=0;
80 while(($row=mysql_fetch_array($result)))
81 {
82 $i++;
83 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
84 ?>
85
86 <tr>
87 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
88 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
89 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
90 <a href="./?act=currency_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Sửa</a></td>
91 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
92 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=currency&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Xoá</a></td>
93 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['id']; ?> </td>
94 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['code']; ?> </td>
95 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
96 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['conver']; ?> </td>
97 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
98 </tr>
99 <?
100 }
101 ?>
102 </table>
103 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
104 </form>
105 <script language="JavaScript">
106 function chkallClick(o) {
107 var form = document.frmList;
108 for (var i = 0; i < form.elements.length; i++) {
109 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
110 form.elements[i].checked = document.frmList.chkall.checked;
111 }
112 }
113 }
114 </script>
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Currency : <b> <a href="./?act=currency_m"><font color="#FFFFFF">Nhập
5 mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $sql = "delete from currency where id='".$id."'";
14 @$result = mysql_query($sql,$con);
15 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
16 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
17 break;
18 }
19 ?>
20
21 <?
22 if (isset($_POST['ButDel'])) {
23 $cnt=0;
24 foreach ($_POST['chk'] as $id)
25 {
26 @$result = mysql_query("delete from currency where id='".$id."'",$con);
27 if ($result) $cnt++;
28 }
29 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
30 }
31 ?>
32 <?
33 $page = $_GET["page"];
34 $MAXPAGE=10;
35 $p=0;
36 if ($page!='') $p=$page;
37 ?>
38 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
39 <input type="hidden" name="act" value="currency">
40 <input type=hidden name="page" value="<? echo $page; ?>">
41 <?
42 function taotrang($sql,$link,$nitem,$itemcurrent)
43 { global $con;
44 $ret="";
45 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
46 $value = mysql_fetch_array($result);
47 $plus = (($value['cnt'] % $nitem)>0);
48 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
49 {
50 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
51 else $ret .= ($i+1)." ";
52 }
53 return $ret;
54 }
55 $pageindex=taotrang("select count(*) from currency","./?act=currency"."&page=",$MAXPAGE,$page);
56 ?>
57
58 <table cellspacing="0" cellpadding="0">
59 <tr>
60 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
61 </tr>
62 </table>
63
64 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
65 <tr>
66 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
67 <td nowrap class="title"> </td>
68 <td nowrap class="title"> </td>
69 <td align="center" nowrap class="title"><b>ID</b></td>
70 <td align="center" nowrap class="title"><b>Mã</b></td>
71 <td align="center" nowrap class="title"><b>Tên tiền</b></td>
72 <td align="center" nowrap class="title"><b>Quy đổi</b></td>
73 <td align="center" nowrap class="title"><b>Thứ tự</b></td>
74 </tr>
75
76 <?
77 $sql="select * from currency order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
78 $result=mysql_query($sql,$con);
79 $i=0;
80 while(($row=mysql_fetch_array($result)))
81 {
82 $i++;
83 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
84 ?>
85
86 <tr>
87 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
88 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
89 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
90 <a href="./?act=currency_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Sửa</a></td>
91 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
92 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=currency&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Xoá</a></td>
93 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['id']; ?> </td>
94 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['code']; ?> </td>
95 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
96 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['conver']; ?> </td>
97 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
98 </tr>
99 <?
100 }
101 ?>
102 </table>
103 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
104 </form>
105 <script language="JavaScript">
106 function chkallClick(o) {
107 var form = document.frmList;
108 for (var i = 0; i < form.elements.length; i++) {
109 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
110 form.elements[i].checked = document.frmList.chkall.checked;
111 }
112 }
113 }
114 </script>